//
//  ZJBaseTabbarViewController.swift
//  Webo
//
//  Created by 曾静 on 16/6/25.
//  Copyright © 2016年 qq. All rights reserved.
//

import UIKit

class ZJBaseTabbarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabbar = ZJTabbar()
        
        setValue(tabbar, forKey: "tabBar");
        
        tabbar.modelClourse = {
            
        //不能push但是能modal
            
            let nav = UINavigationController(rootViewController: ZJComposeViewController())
            
            self.presentViewController(nav, animated: true, completion: nil)
        }
        
        addControllers()
    }
    
    func addControllers(){
        
        addViewControllers(ZJHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addViewControllers(ZJMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addViewControllers(ZJDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addViewControllers(ZJProfileTableViewController(), title: "我", imageName: "tabbar_profile")

    }
    
    func addViewControllers(vc:UIViewController,title:String,imageName:String){
        
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        
        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")
        
        let nav = UINavigationController(rootViewController: vc)
        
        addChildViewController(nav)
        
    }

}
